<!--  -->
<template>
  <div id="detail">
    <detail-nav-bar></detail-nav-bar>
    <datail-swiper :topImages="topImages"></datail-swiper>
    <datail-base-info :goods="goods"></datail-base-info>
  </div>
</template>

<script>
import DetailNavBar from "../../views/detail/DetailChild/DetailNavBar";
import DatailSwiper from "../../views/detail/DetailChild/datailSwiper";
import datailBaseInfo from "../../views/detail/DetailChild/detailbaseInfo";

import { getDetail, Goods } from "../../network/datail";

export default {
  name: "detail",
  data() {
    return {
      iid: null,
      topImages: [],
      goods: {},
    };
  },
  created() {
    //保存本地的iid
    this.iid = this.$route.params.iid;
    //请求详情数据
    getDetail(this.iid).then((res) => {
      console.log(res);
      //获取顶部的轮播图图片
      this.topImages = res.result.itemInfo.topImages;
      //获取商品数据
      this.goods = new Goods(
        res.result.itemInfo,
        res.result.columns,
        res.result.shopInfo.services
      );
    });
  },
  components: {
    DetailNavBar,
    DatailSwiper,
    datailBaseInfo,
  },
};
</script>
<style  scoped>
</style>